import tornado.ioloop
import tornado.web
import sys, asyncio
# import pymysql
from controller import (index,gender,school,occupation,topic,persion,users_count,location,relation,)

if sys.platform == 'win32':
	asyncio.set_event_loop_policy(\
	asyncio.WindowsSelectorEventLoopPolicy())

def make_app():
	
	import os, sys
	
	_dir_ = os.getcwd()
	
	settings = {
		'template_path':	_dir_ + '/template',
		'static_path':	_dir_ + '/static'
	}

	return tornado.web.Application([
        # (r"/", MainHandler),
		(r"/stop", index.stop),
		(r"/login",index.LoginHandler),
		(r"/register",index.RegisterHandler),
		(r"/index",index.IndexHandler),
        # (r"/api/data",index.Index_data),
        
       
        (r"/topic",topic.topicHandler),
        # (r"/api/topic_data",topic.topic_data),

        (r"/gender",gender.GenderHandler),
        (r"/api/gender_data",gender.gender_data),

        (r"/occupation",occupation.OccupationHandler),
        # (r"/api/occupation_data",occupation.occupation_data),

        (r"/school",school.SchoolHandler),
        # (r"/api/school_data",school.school_data),

        (r"/location",location.LocationHandler),
          (r"/relation",relation.RelationHandler),

        (r"/users_count",users_count. Users_countHandler),
        # (r"/api/count_data",users_count.count_data),
         
        (r"/persion",persion.PersionHandler),
    ], **settings)

if __name__ == "__main__":
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()
